#!/bin/bash -x


INSTSET=`echo $* | grep '\--install_set' | sed -e 's/.*--install_set\=//' -e 's/ .*//'`

if [ -z "$INSTSET" ]; then
    echo skipping since no upload is required
    exit 65
fi

# put name of OOo config file created by configure in $envname
. ../../getOOoEnv
. $envname

export zipname=install_set.zip

rm $zipname
rm $zipname.filelist

[ -f winenv.set.sh ] && source winenv.set.sh

cd instsetoo_native/$INPATH

if [ -z $WITH_LANG ]; then
    WITH_LANG=en-US
fi

if [ $envname == "winenv.set.sh" -a -z "$PKGFORMAT" ]; then
    PKGFORMAT=msi
fi

for product in OpenOffice URE ; do
    for lang in $WITH_LANG ; do
        if [ -d $product/$PKGFORMAT/install/${lang}_download  -a "`ls $product/$PKGFORMAT/install/${lang}_download/`" ]; then
            find $product/$PKGFORMAT/install/${lang}_download -type f -print >> ../../$zipname.filelist
        elif [ -d $product/$PKGFORMAT/install/$lang ]; then
            find $product/$PKGFORMAT/install/$lang -type f -print >> ../../$zipname.filelist
        fi
    done
done

cat ../../$zipname.filelist|zip -0 ../../$zipname -@
rcode=$?

cd ../..

ls -l $zipname
md5sum $zipname

exit $rcode

